package com.lcredu.seckill.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 黎长容
 * @date 2025-09-12 15:05
 */
@Configuration
public class RabbitSeckillMessageConfig {
    public static final String SECKILLMESSAGEQUEUE = "seckillMessageQueue01";
    public static final String SECKILLTOPICEXCHANGE01 = "seckillTopicExchange01";

    //创建队列
    @Bean
    public Queue seckillQueue() {
        return new Queue(SECKILLMESSAGEQUEUE);
    }

    //创建交换机
    @Bean
    public TopicExchange seckillTopicExchange() {
        return new TopicExchange(SECKILLTOPICEXCHANGE01);
    }

    //绑定
    @Bean
    public Binding binding() {
        return BindingBuilder.bind(seckillQueue()).to(seckillTopicExchange()).with("seckill.#");
    }

}
